package com.xiejr.actuator.controller;

import com.xiejr.actuator.entity.constant.ConstantConfig;
import com.xiejr.actuator.model.ResultVO;
import com.xiejr.actuator.model.SecurityModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @program: socket-actuator-spring-boot-starter
 * @description: 安全模式接口
 * @author: xjr
 * @create: 2020-06-29 17:07
 **/
@RestController
@ApiIgnore
@Lazy
@RequestMapping(ConstantConfig.PREFIX+"/security")
public class SecurityController {

    private SecurityModel securityModel;


    public SecurityController( @Autowired(required = false)SecurityModel securityModel){
        this.securityModel=securityModel;
    }

    @GetMapping("")
    public ResultVO get(){
        if (securityModel==null){
            return ResultVO.data(null);
        }
        SecurityModel res=new SecurityModel();
        res.setFullName(securityModel.getFullName());
        res.setPassWay(securityModel.getPassWay());
        res.setPassword(securityModel.getPassword());
        res.setUserName(securityModel.getUserName());
        return ResultVO.data(res);
    }
}
